<!--
 *************************************************************************
 * The contents of this file are subject to the Openbravo  Public  License
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
 * Version 1.1  with a permitted attribution clause; you may not  use this
 * file except in compliance with the License. You  may  obtain  a copy of
 * the License at http://www.openbravo.com/legal/license.html 
 * Software distributed under the License  is  distributed  on  an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific  language  governing  rights  and  limitations
 * under the License. 
 * The Original Code is Openbravo ERP. 
 * The Initial Developer of the Original Code is Openbravo SLU 
 * All portions are Copyright (C) 2008-2010 Openbravo SLU 
 * All Rights Reserved. 
 * Contributor(s):  ______________________________________.
 ************************************************************************
-->
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Create Purchase Order</title>
  <link rel="shortcut icon" href="../../../../../web/images/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="../../../../../web/skins/Default/Openbravo_ERP_250.css" id="paramCSS"></link>
  <script language="JavaScript" src="../../../../../web/js/ajax.js" type="text/javascript"></script>
  <script language="JavaScript" src="../utility/DynamicJS.js" type="text/javascript"></script>
  <script language="JavaScript" src="../../../../../web/js/default/MessageBox.js" type="text/javascript"></script>
  <script language="JavaScript" type="text/javascript" id="paramLanguage">defaultLang = "en_US";</script>
  <script language="JavaScript" src="../../../../../web/js/shortcuts.js" type="text/javascript"></script>
  <script language="JavaScript" src="../../../../../web/js/utils.js" type="text/javascript"></script>
  <script language="JavaScript" src="../../../../../web/js/messages.js" type="text/javascript"></script>
  <script language="JavaScript" src="../../../../../web/js/windowKeyboard.js" type="text/javascript"></script>
  <script language="JavaScript" src="../../../../../web/js/searchs.js" type="text/javascript"></script>
  <script language="JavaScript" src="../../../../../web/js/jscalendar/calendar.js" type="text/javascript"></script>
  <script language="JavaScript" src="../../../../../web/js/jscalendar/lang/calendar-es.js" type="text/javascript" id="fieldCalendar"></script>
  <script language="JavaScript" src="../../../../../web/js/default/DateTextBox.js" type="text/javascript"></script>
  <script language="JavaScript" src="../../../../../web/js/dojoConfig.js" type="text/javascript"></script>
  <script language="JavaScript" src="../../../../../web/js/dojo/dojo.js" type="text/javascript"></script>
  <script type="text/javascript">
    window.onunload = reloadOpener; // reloads opener on closing
    dojo.hostenv.writeIncludes(); //makes debugging in Venkman possible
  </script>
  <script language="JavaScript" type="text/javascript" id="paramDirectory">
    var baseDirectory="../../../../../web/";
  </script>
  <script language="JavaScript" type="text/javascript">
    function closeThisPage() {
      window.close();
      return true;
    }

    function submitThisPage(strCommand) {
      if (document.frmMain.inpSelected.value=="") {
        window.opener.submitCommandForm("FIND", true, null, null, "_self");
        closeThisPage();
      } else {
        submitCommandForm(strCommand, true, null, null, "_top");
      }
      return true;
    }
      function validate(action) {
        var frm=document.frmMain;
        if (frm.inpOrderDate.value==null || frm.inpOrderDate.value=="") {
            setWindowElementFocus(frm.inpOrderDate);
            showJSMessage(7);
            return false;
        }
        if (frm.inpOrderVendorId.value==null || frm.inpOrderVendorId.value=="") {
            setWindowElementFocus(frm.inpOrderVendorId_DES);
            showJSMessage(7);
            return false;
        }
        if (frm.inpPriceListId.value==null || frm.inpPriceListId.value=="") {
            setWindowElementFocus(frm.inpPriceListId);
            showJSMessage(7);
            return false;
        }
        if (frm.inpOrderOrg.value==null || frm.inpOrderOrg.value=="") {
            setWindowElementFocus(frm.inpOrderOrg);
            showJSMessage(7);
            return false;
        }
        if (frm.inpWarehouse.value==null || frm.inpWarehouse.value=="") {
            setWindowElementFocus(frm.inpWarehouse);
            showJSMessage(7);
            return false;
        }
        return true;
      }

    function displayLogic() {
      if (inputValue(document.frmMain.inpSelected) == '') {
        displayLogicElement('displayLogicCancel', false);
      } else {
        displayLogicElement('displayLogicCancel', true);
        document.getElementById("dlOrderDate").style.display="";
        document.getElementById("dlVendor").style.display="";
        document.getElementById("dlPriceList").style.display="";
        document.getElementById("dlOrg").style.display="";
        document.getElementById("dlWarehouse").style.display="";
      }
      return true;
    }
    function refreshWarehouse() {
      var cmbOrg = document.frmMain.inpOrderOrg;
      var cmbWarehouse = document.frmMain.inpWarehouse;
      changeComboData(cmbWarehouse, arrWarehouse, cmbOrg.options[cmbOrg.selectedIndex].value, false);
      for (var i = 0; i < cmbWarehouse.options.length; i++) {
          if (cmbWarehouse.options[i].value === document.getElementById("paramLoginWarehouseId").value) {
        	  cmbWarehouse.selectedIndex = i;
        	  break;
          }
      }
      return true;
    }
  </script>
  <script language="JavaScript" type="text/javascript" id="paramArrayWarehouse">
    var arrWarehouse=null;
  </script>
    <script language="JavaScript" type="text/javascript">
      function onLoadDo(){
        this.windowTables = new Array(
          new windowTableId('client', 'buttonOK')
        );
        setWindowTableParentElement();
        enableShortcuts('popup');
        setBrowserAutoComplete(false);

        displayLogic();
        xx();
        refreshWarehouse();

        setWindowElementFocus('firstElement');
      }

      function onResizeDo(){
      }
    </script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"  onload="onLoadDo();" id="paramMessage">
  <form id="form" method="post" action="RequisitionToOrderCreate.html" name="frmMain" target="hiddenFrame">
    <input type="hidden" name="Command"></input>
    <input type="hidden" name="IsPopUpCall" value="1"></input>
    <input type="hidden" name="inpLastFieldChanged"></input>
    <input type="hidden" name="inpSelected" id="paramSelected" value=""></input>
    <input type="hidden" name="inpLoginWarehouseId" id="paramLoginWarehouseId" value=""></input>
    <div class="Popup_ContentPane_CircleLogo">
      <div class="Popup_WindowLogo">
        <img class="Popup_WindowLogo_Icon Popup_WindowLogo_Icon_process" src="../../../../../web/images/blank.gif" border=0/></img>
      </div>
    </div>

    <table cellspacing="0" cellpadding="0" width="100%">

      <tr>
        <td>
          <table cellspacing="0" cellpadding="0" class="Popup_ContentPane_NavBar">
            <tr class="Popup_NavBar_bg"><td></td>
              <td class="Popup_NavBar_separator_cell"></td>
              <td class="Popup_NavBar_bg_logo_left"></td>
              <td class="Popup_NavBar_bg_logo" width="1" onclick="openNewBrowser('http://www.openbravo.com', 'Openbravo');return false;"><img src="../../../../../web/images/blank.gif" alt="Openbravo" title="Openbravo" border="0" id="openbravoLogo" class="Popup_NavBar_logo" /></td>
              <td class="Popup_NavBar_bg_logo_right"></td>
              <td class="Popup_NavBar_Popup_title_cell"><span>Create Purchase Order</span></td>
              <td class="Popup_NavBar_separator_cell"></td>
            </tr>
          </table>
        </td>
      </tr>

      <tr>
        <td>
          <table cellspacing="0" cellpadding="0" class="Popup_ContentPane_SeparatorBar">
            <tr>
              <td class="Popup_SeparatorBar_bg"></td>
            </tr>
          </table>
        </td>
      </tr>

      <tr>
        <td>
          <table cellspacing="0" cellpadding="0" class="Popup_ContentPane_InfoBar">
            <tr>
              <td class="Popup_InfoBar_Icon_cell"><img src="../../../../../web/images/blank.gif" border="0" class="Popup_InfoBar_Icon_info" /></td>
              <td class="Popup_InfoBar_text_table">
                <table>
                  <tr>
                    <td class="Popup_InfoBar_text" id="helpDiscard"> <div id="processHelp">&nbsp;</div></td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <div class="Popup_ContentPane_Client" style="overflow: auto;" id="client">
            <!-- MessageBox -->
            <table cellpadding="0" cellspacing="0" id="messageBoxID" class="MessageBoxyy">
              <tbody>
                <tr class="MessageBox_TopMargin">
                  <td class="MessageBox_LeftMargin"></td>
                  <td></td>
                  <td class="MessageBox_RightMargin"></td>
                </tr>
                <tr>
                  <td class="MessageBox_LeftMargin"></td>
                  <td>

                    <table cellpadding="0" cellspacing="0" class="MessageBox_Container">
                      <tbody>
                        <tr>
                          <td class="MessageBox_LeftTrans">
                            <table style="width: 100%; height: 100%" cellpadding="0" cellspacing="0">
                              <tbody>
                              <tr>
                                <td class="MessageBox_TopLeft"></td>
                              </tr>
                              <tr>
                                <td class="MessageBox_Left"></td>
                              </tr>
                              </tbody>
                            </table>
                          </td>
                          <td class="MessageBox_bg">

                            <table class="MessageBox_Top">
                              <tbody>
                                <tr>
                                  <td>
                                    <span>
                                      <table cellpadding="0" cellspacing="0" class="MessageBox_Body_ContentCell">
                                        <tbody>
                                          <tr>
                                            <td class="MessageBox_Icon_ContentCell">
                                              <div class="MessageBox_Icon"></div>
                                            </td>
                                            <td style="vertical-align: top;" id="messageBoxIDContent">
                                              <span>
                                                <div class="MessageBox_TextTitle" id="messageBoxIDTitle">
                                                  xxInfo: AccessTableWithNoView
                                                </div>
                                                <div class="MessageBox_TextDescription" id="messageBoxIDMessage">
                                                  xxThe current information is empty.
                                                </div>
                                                <div class="MessageBox_TextSeparator"></div>
                                              </span>
                                            </td>
                                          </tr>
                                        </tbody>
                                      </table>
                                    </span>
                                  </td>
                                </tr>
                              </tbody>
                            </table>

                          </td>
                          <td class="MessageBox_RightTrans">
                            <table style="width: 100%; height: 100%" cellpadding="0" cellspacing="0">
                              <tbody>
                              <tr>
                                <td class="MessageBox_TopRight"></td>
                              </tr>
                              <tr>
                                <td class="MessageBox_Right"></td>
                              </tr>
                              </tbody>
                            </table>
                          </td>
                        </tr>
                        <tr>
                          <td rowspan="2" class="MessageBox_BottomLeft">
                          </td>
                          <td class="MessageBox_BottomTrans MessageBox_bg">
                          </td>
                          <td rowspan="2" class="MessageBox_BottomRight">
                          </td>
                        </tr>
                        <tr>
                          <td class="MessageBox_Bottom">
                          </td>
                        </tr>
                      </tbody>
                    </table>

                  </td>
                  <td class="MessageBox_RightMargin"></td>
                </tr>
                <tr class="MessageBox_BottomMargin">
                  <td class="MessageBox_LeftMargin"></td>
                  <td></td>
                  <td class="MessageBox_RightMargin"></td>
                </tr>
              </tbody>
            </table>
            <!-- MessageBox END -->

            <table cellspacing="0" cellpadding="0" class="Popup_Client_TablePopup">
              <tr>
                <td class="TableEdition_OneCell_width"></td>
                <td class="TableEdition_OneCell_width"></td>
                <td class="TableEdition_OneCell_width"></td>
                <td class="TableEdition_OneCell_width"></td>
              </tr>
              
              <tr style="display:none" id="dlOrderDate">
                <td class="TitleCell"><span class="LabelText">Order Date</span></td>
                <td class="TextBox_btn_ContentCell">
                  <table border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
                    <tr>
                      <td class="TextBox_ContentCell">
                        <input dojotype="openbravo:DateTextbox" displayformat="xx" saveformat="xx"  class="dojoValidateValid TextBox_btn_OneCell_width required" required="true" type="text" name="inpOrderDate" id="paramOrderDate" size="10" maxlength="10" value="" onkeyup="autoCompleteDate(this.textbox, this.displayFormat);return true;"></input><script>djConfig.searchIds.push("paramOrderDate");</script>
                      </td>
                      <td class="FieldButton_ContentCell">
                        <a class="FieldButtonLink" href="#" onfocus="this.className='FieldButtonLink_hover'; window.status='Calendar'; return true;" onblur="this.className='FieldButtonLink'; window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_hover'; return true;"  onclick="showCalendar('frmMain.paramOrderDate', document.frmMain.paramOrderDate.value, false);return false;">
                          <table class="FieldButton" onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Show calendar';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
                            <tr>
                              <td class="FieldButton_bg">
                                <img alt="Calendar" class="FieldButton_Icon FieldButton_Icon_Calendar" title="Calendar" src="../../../../../web/images/blank.gif" border="0"></img>
                              </td>
                            </tr>
                          </table>
                        </a>
                      </td>
                    </tr>
                  </table>
                </td>
                <td class="TitleCell"></td>
                <td class="TitleCell"></td>
              </tr>
              <tr id="dlVendor" style="display: none">
                <td class="TitleCell"> <span class="LabelText">Vendor</span></td>
                <td class="TextBox_btn_ContentCell" colspan="2">
                  <table border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
                    <tr>
                      <td class="TextBox_ContentCell">
                        <input type="hidden" name="inpOrderVendorId" value="" id="paramOrderVendorId"></input> 
                        <input class="dojoValidateValid TextBox_btn_TwoCells_width required" required="true" type="text"  name="inpOrderVendorId_DES" maxlength="20" value="" id="paramOrderVendorDescription"></input>
                      </td>
                      <td class="FieldButton_ContentCell">
                        <a class="FieldButtonLink" href="#" onfocus="this.className='FieldButtonLink_hover'; window.status='Business Partner'; return true;" onblur="this.className='FieldButtonLink'; window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_hover'; return true;"  onclick="openSearch(null, null, '../info/BusinessPartner.html', 'SELECTOR_BUSINESS', false, 'frmMain', 'inpOrderVendorId', 'inpOrderVendorId_DES', document.frmMain.inpOrderVendorId_DES.value, 'WindowID', 'RequisitionToOrderCreate');return false;">
                          <table class="FieldButton" onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Business Partner';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
                            <tr>
                              <td class="FieldButton_bg">
                                <img alt="Business Partner" class="FieldButton_Icon FieldButton_Icon_BusinessPartner" title="Business Partner" src="../../../../../web/images/blank.gif" border="0"></img>
                              </td>
                            </tr>
                          </table>
                        </a>
                      </td>
                    </tr>
                  </table>
                </td>
                <td class="TitleCell"></td>
              </tr>
              <tr id="dlPriceList" style="display: none">
                <td class="TitleCell"> <span class="LabelText">Price list</span></td>
                <td class="Combo_ContentCell" colspan="2"> <select name="inpPriceListId"  class="ComboKey Combo_TwoCells_width" required="true" id="inpPriceListId"><div id="reportPriceList_ID"><option value=""></option></div>
                </select></td>
                <td class="TitleCell"></td>
              </tr>
              <tr id="dlOrg" style="display: none">
                <td class="TitleCell"> <span class="LabelText">Organization</span></td>
                <td class="Combo_ContentCell" colspan="2"> <select name="inpOrderOrg"  class="ComboKey Combo_TwoCells_width" required="true" id="inpOrderOrg" onchange="refreshWarehouse();"><option value=""></option><div id="reportOrderOrg_ID"></div>
                </select></td>
                <td class="TitleCell"></td>
              </tr>
              <tr id="dlWarehouse" style="display: none">
                <td class="TitleCell"> <span class="LabelText">Warehouse</span></td>
                <td class="Combo_ContentCell" colspan="2"> <select name="inpWarehouse"  class="ComboKey Combo_TwoCells_width" required="true" id="inpWarehouse"><div id="reportWarehouse_ID"><option value=""></option></div>
                </select></td>
                <td class="TitleCell"></td>
              </tr>

              <tr>
                <td></td>
                <td class="Button_RightAlign_ContentCell">
                  <div>
                    <button type="button" 
                      id="buttonOK" 
                      class="ButtonLink" 
                      onclick="submitThisPage('GENERATE');return false;" 
                      onfocus="buttonEvent('onfocus', this); window.status='Accept'; return true;" 
                      onblur="buttonEvent('onblur', this);" 
                      onkeyup="buttonEvent('onkeyup', this);" 
                      onkeydown="buttonEvent('onkeydown', this);" 
                      onkeypress="buttonEvent('onkeypress', this);" 
                      onmouseup="buttonEvent('onmouseup', this);" 
                      onmousedown="buttonEvent('onmousedown', this);" 
                      onmouseover="buttonEvent('onmouseover', this); window.status='Accept'; return true;" 
                      onmouseout="buttonEvent('onmouseout', this);">
                      <table class="Button">
                        <tr>
                          <td class="Button_left"><img class="Button_Icon Button_Icon_ok" alt="Accept" title="Accept" src="../../../../../web/images/blank.gif" border="0" /></td>
                          <td class="Button_text Button_width">OK</td>
                          <td class="Button_right"></td>
                        </tr>
                      </table>
                    </button>
                  </div>
                </td>
                <td class="Button_LeftAlign_ContentCell" id="displayLogicCancel">
                  <button type="button" 
                    id="buttonCancel" 
                    class="ButtonLink" 
                    onclick="closeThisPage();return false;" 
                    onfocus="buttonEvent('onfocus', this); window.status='Cancel'; return true;" 
                    onblur="buttonEvent('onblur', this);" 
                    onkeyup="buttonEvent('onkeyup', this);" 
                    onkeydown="buttonEvent('onkeydown', this);" 
                    onkeypress="buttonEvent('onkeypress', this);" 
                    onmouseup="buttonEvent('onmouseup', this);" 
                    onmousedown="buttonEvent('onmousedown', this);" 
                    onmouseover="buttonEvent('onmouseover', this); window.status='Cancel'; return true;" 
                    onmouseout="buttonEvent('onmouseout', this);">
                    <table class="Button">
                      <tr>
                        <td class="Button_left"><img class="Button_Icon Button_Icon_cancel" alt="Cancel" title="Cancel" src="../../../../../web/images/blank.gif" border="0" /></td>
                        <td class="Button_text Button_width">Cancel</td>
                        <td class="Button_right"></td>
                      </tr>
                    </table>
                  </button>
                </td>
                <td></td>
              </tr>

            </table>
          </div>
        </td>
      </tr>
    </table>
  </form>
</body>
</html>
